// 定义 HomeInfoModel 类，实现可序列化
class HomeInfoModel {
  int code;
  String msg;
  HomeInfoModelClassModel? data;

  HomeInfoModel({
    required this.code,
    required this.msg,
    this.data,
  });

  // 从 JSON 数据创建 HomeInfoModel 实例
  factory HomeInfoModel.fromJson(Map<String, dynamic> json) {
    return HomeInfoModel(
      code: json['code'] as int,
      msg: json['msg'] as String,
      data: json['data'] != null
          ? HomeInfoModelClassModel.fromJson(json['data'] as Map<String, dynamic>)
          : null,
    );
  }
}

// 定义 HomeInfoModelClassModel 类，包含各种列表数据
class HomeInfoModelClassModel {
  List<AdListModel> adList;
  List<HotCategoryListModel> hotCategoryList;
  List<LikeListModel> likeList;
  List<NewListModel> newList;
  List<RechargeListModel> rechargeList;

  HomeInfoModelClassModel({
    required this.adList,
    required this.hotCategoryList,
    required this.likeList,
    required this.newList,
    required this.rechargeList,
  });

  // 从 JSON 数据创建 HomeInfoModelClassModel 实例
  factory HomeInfoModelClassModel.fromJson(Map<String, dynamic> json) {
    return HomeInfoModelClassModel(
      adList: (json['adList'] as List<dynamic>?)
              ?.map((e) => AdListModel.fromJson(e as Map<String, dynamic>))
              .toList() ??
          [],
      hotCategoryList: (json['hotCategoryList'] as List<dynamic>?)
              ?.map((e) => HotCategoryListModel.fromJson(e as Map<String, dynamic>))
              .toList() ??
          [],
      likeList: (json['likeList'] as List<dynamic>?)
              ?.map((e) => LikeListModel.fromJson(e as Map<String, dynamic>))
              .toList() ??
          [],
      newList: (json['newList'] as List<dynamic>?)
              ?.map((e) => NewListModel.fromJson(e as Map<String, dynamic>))
              .toList() ??
          [],
      rechargeList: (json['rechargeList'] as List<dynamic>?)
              ?.map((e) => RechargeListModel.fromJson(e as Map<String, dynamic>))
              .toList() ??
          [],
    );
  }
}

// 定义 AdListModel 类，包含广告列表信息
class AdListModel {
  String cover;
  String jumpUrl;
  String name;
  String spuId;

  AdListModel({
    required this.cover,
    required this.jumpUrl,
    required this.name,
    required this.spuId,
  });

  // 从 JSON 数据创建 AdListModel 实例
  factory AdListModel.fromJson(Map<String, dynamic> json) {
    return AdListModel(
      cover: json['cover'] as String,
      jumpUrl: json['jumpUrl'] as String,
      name: json['name'] as String,
      spuId: json['spuId'] as String,
    );
  }
}

// 定义 ArticleListModel 类，包含文章列表信息
// class ArticleListModel {
//   String cover;
//   String id;
//   String title;

//   ArticleListModel({
//     required this.cover,
//     required this.id,
//     required this.title,
//   });

//   // 从 JSON 数据创建 ArticleListModel 实例
//   factory ArticleListModel.fromJson(Map<String, dynamic> json) {
//     return ArticleListModel(
//       cover: json['cover'] as String,
//       id: json['id'] as String,
//       title: json['title'] as String,
//     );
//   }
// }

// 定义 HotCategoryListModel 类，包含热门分类列表信息
class HotCategoryListModel {
  String name;
  String pic;
  String tag;
  List<HotListModel> children;

  HotCategoryListModel({
    required this.name,
    required this.pic,
    required this.tag,
    required this.children,
  });

  // 从 JSON 数据创建 HotCategoryListModel 实例
  factory HotCategoryListModel.fromJson(Map<String, dynamic> json) {
    return HotCategoryListModel(
      name: json['name'] as String,
      pic: json['pic'] as String,
      tag: json['tag'] as String,
      children: (json['children'] as List<dynamic>?)
              ?.map((e) => HotListModel.fromJson(e as Map<String, dynamic>))
              .toList() ??
          [],
    );
  }
}

// 定义 LikeListModel 类，包含喜欢列表信息
class LikeListModel {
  int id;
  String name;
  String pic;

  LikeListModel({
    required this.id,
    required this.name,
    required this.pic,
  });

  // 从 JSON 数据创建 LikeListModel 实例
  factory LikeListModel.fromJson(Map<String, dynamic> json) {
    return LikeListModel(
      id: json['id'] as int,
      name: json['name'] as String,
      pic: json['pic'] as String,
    );
  }
}

// 定义 NewListModel 类，包含新列表信息
class NewListModel {
  int id;
  String name;
  String pic;
  String cover;
  String infor;

  NewListModel({
    required this.id,
    required this.name,
    required this.pic,
    required this.cover,
    required this.infor,
  });

  // 从 JSON 数据创建 NewListModel 实例
  factory NewListModel.fromJson(Map<String, dynamic> json) {
    return NewListModel(
      id: json['id'] as int,
      name: json['name'] as String,
      pic: json['pic'] as String,
      cover: json['cover'] as String,
      infor: json['infor'] as String,
    );
  }
}

// 定义 RechargeListModel 类，包含充值列表信息
class RechargeListModel {
  int id;
  int spuId;
  int attrId;
  String name;
  String pic;
  String infor;
  // List<ChildrenListModel> children;

  RechargeListModel({
    required this.id,
    required this.spuId,
    required this.attrId,
    required this.name,
    required this.pic,
    required this.infor,
    // required this.children,
  });

  // 从 JSON 数据创建 RechargeListModel 实例
  factory RechargeListModel.fromJson(Map<String, dynamic> json) {
    return RechargeListModel(
      id: json['id'] as int,
      spuId: json['spuId'] as int,
      attrId: json['attrId'] as int,
      name: json['name'] as String,
      pic: json['pic'] as String,
      infor: json['infor'] as String,
      // children: (json['children'] as List<dynamic>?)
      //         ?.map((e) => ChildrenListModel.fromJson(e as Map<String, dynamic>))
      //         .toList() ??
      //     [],
    );
  }
}

// 定义 ChildrenListModel 类，包含子列表信息
class ChildrenListModel {
  int id;
  int attrId;
  String attrName;
  String marketPrice;
  String priceFee;
  String symbol;

  ChildrenListModel({
    required this.id,
    required this.attrId,
    required this.attrName,
    required this.marketPrice,
    required this.priceFee,
    required this.symbol,
  });

  // 从 JSON 数据创建 ChildrenListModel 实例
  factory ChildrenListModel.fromJson(Map<String, dynamic> json) {
    return ChildrenListModel(
      id: json['id'] as int,
      attrId: json['attrId'] as int,
      attrName: json['attrName'] as String,
      marketPrice: json['marketPrice'] as String,
      priceFee: json['priceFee'] as String,
      symbol: json['symbol'] as String,
    );
  }
}

// 定义 HotListModel 类，包含热门列表信息
class HotListModel {
  int id;
  String name;
  String pic;

  HotListModel({
    required this.id,
    required this.name,
    required this.pic,
  });

  // 从 JSON 数据创建 HotListModel 实例
  factory HotListModel.fromJson(Map<String, dynamic> json) {
    return HotListModel(
      id: json['id'] as int,
      name: json['name'] as String,
      pic: json['pic'] as String,
    );
  }
}